package com.acme.bankapp.domain.bank;

/**
 * Created by Student on 18.08.2014.
 */
public class Client {

    private Account account;
    private String name;
    private Gender gender;

    public Client(String name, Gender gender, Account account) {
        this.account = account;
        this.name = name;
        this.gender = gender;
    }

    public Client(Account account) {
        this.account = account;
        this.name = "Smith";
        this.gender=Gender.MALE;
    }

    public String getName() {
        return name;
    }

    public String getSalutation() {
        return gender.salutation;
    }

    public Account getAccounts() {
        return account;
    }

    @Override
    public String toString() {
        return new StringBuffer(gender.salutation).append(name).append(account).toString();
    }

    @Override
    public boolean equals(Object o) {

        if (o == null) return false;
        if (o == this) return true;
        if ( ! (o instanceof Client)) return false;

        Client tmp = (Client)o;

        if (tmp.getName().equals(this.getName()) && (tmp.gender.equals(this.gender) ))
            return true;

        return false;
    }

    @Override
    public int hashCode() {
        int result = 0;
        result = 31* name.hashCode() + gender.salutation.hashCode();
        return result;
    }

    public Gender getGender() {
        return gender;
    }
}

